package com.tianzeculture.stagebao.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by Administrator on 2018/8/14.
 */

public class MyRecyclerview extends RecyclerView {
    public MyRecyclerview(Context context) {
        super(context);
    }

    public MyRecyclerview(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecyclerview(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * 其中onMeasure函数决定了组件显示的高度与宽度；
     * makeMeasureSpec函数中第一个函数决定布局空间的大小，第二个参数是布局模式
     * MeasureSpec.AT_MOST的意思就是子控件需要多大的控件就扩展到多大的空间
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }

//    @Override
//    public boolean onTouchEvent(MotionEvent e) {
//        switch (e.getAction()) {
//            case MotionEvent.ACTION_DOWN://0
////                        Log.e("TAG", "LinearLayout onTouchEvent 按住");
//                break;
//            case MotionEvent.ACTION_UP://1
//                getParent().requestDisallowInterceptTouchEvent(true);
////                           Log.e("TAG", "LinearLayout onTouchEvent onTouch抬起");
//                break;
//            case MotionEvent.ACTION_MOVE://2
//                getParent().requestDisallowInterceptTouchEvent(false);
////                          Log.e("TAG", "LinearLayout onTouchEvent 移动");
//                break;
//        }
//        return super.onTouchEvent(e);
//    }
}
